package cn.itsource.hrm.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author jinhui
 * @version V1.0.0
 * @date 2020/6/5
 */
@Configuration
public class RabbitmqConfig {
    private static final String EXCHANG_NAME="hrm-couseTypes2";
    public static final String QUEUE_NAME = "page-agent-2";
    //声明交换机
    @Bean(EXCHANG_NAME)
    public Exchange EXCHANG_NAME(){
        return ExchangeBuilder.directExchange(EXCHANG_NAME).durable(true).build();
    }
    //声明队列
    @Bean(QUEUE_NAME)
    public Queue QUEUE_NAME2(){
        Queue queue = new Queue(QUEUE_NAME);
        return queue;
    }
    //将队列绑定到交换机
    @Bean
    public Binding BIND_QUEUE_NAME(@Qualifier(QUEUE_NAME)Queue queue,@Qualifier(EXCHANG_NAME) Exchange exchange ){
        return BindingBuilder.bind(queue).to(exchange).with("page.couse.home").noargs();
    }
}
